﻿<Window x:Class="ProxyViewModel.Samples.TodoList.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen" MinHeight="300" MinWidth="300"
		xmlns:local="clr-namespace:ProxyViewModel.Samples.TodoList.Views">
	<Window.Resources>
		<local:StatusImageConverter x:Key="statusImageConverter"/>
	</Window.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<GroupBox Grid.Row="0" Header="Add new task">
			<StackPanel Orientation="Horizontal">
				<Label Content="Description:"></Label>
				<TextBox Name="_txtDescr" Width="300" Height="25"/>
				<Button Content="Add task" HorizontalAlignment="Left" Margin="3" Command="{Binding AddTask}" CommandParameter="{Binding ElementName=_txtDescr, Path=Text}"/>
			</StackPanel>
			
		</GroupBox>
		
		<GroupBox Header="Current tasks" Grid.Row="1">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition Height="35"/>
				</Grid.RowDefinitions>
				<!-- ListView with tasks -->
				<ListView Grid.Row="0" Margin="3" ItemsSource="{Binding TodoList}"  Name="_taskList">
					<ListView.ItemTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal">
								<Image Source="{Binding IsCompleted, Converter={StaticResource statusImageConverter}}"  />
								<Label Content="{Binding Description}"/>
							</StackPanel>
						</DataTemplate>
					</ListView.ItemTemplate>
				</ListView>
				<StackPanel Grid.Row="1" Orientation="Horizontal">
					<!-- Binding buttons directly to the functions in TaskManagerViewModel -->
					<!-- This button will be bound to AddTaskCommand function -->
				
					<!-- This button will be bound to CompletCommand function. CanExecuteCompleteCommand will be predicate for this button's command -->
					<Button Content="Complete selected" HorizontalAlignment="Left" Margin="3" Command="{Binding Complete}"  CommandParameter="{Binding ElementName=_taskList, Path=SelectedItems}"/>
				</StackPanel>
			</Grid>
		</GroupBox>
	</Grid>
</Window>
